package icegps.com.pingdj.map.utils;

/**
 * Created by 111 on 2018/2/27.
 */

public class DispersionToColor {

    private static int colorIndex = 11;
    private static int colorIndexAdd;
    private static int[] colors = {
            0xFF030389,
            0xFF0702ba,
            0xFF032bd8,
            0xFF003dff,
            0xFF004fff,
            0xFF0074ff,
            0xFF0073BA,
            0xFF01A5F2,
            0xFF089DC3,
            0xFF1098C7,
            0xFF079B97,
            0xFF059D75,
            0xFF05912D,
            0xFF41AA05,
            0xFF41AA05,
            0xFF9CC900,
            0xFFff9700,
            0xFFff6d00,
            0xFFff3c00,
            0xFFff0000,
            0xFFe50505,
            0xFFc60505,
            0xFFb20606,
            0xFFa00707};

    public static int getcolor(double dispersion) {
        if (Math.abs(dispersion) <= 10) {
            colorIndexAdd = (int) (dispersion / 2);
        } else {
            colorIndexAdd = (int) (dispersion / 5);
        }
        if (colorIndexAdd > 11) {
            colorIndexAdd = 11;
        }
        if (colorIndexAdd < -11) {
            colorIndexAdd = -11;
        }

        int color = colors[colorIndexAdd + colorIndex];
        return color;
    }
}
